<?php

namespace app\api\controller;

use app\common\controller\Api;

/**
 * HTTP服务接口
 */
class HttpServer extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     *demo
     */
    public function demo()
    {
        $http = new \Swoole\Http\Server('0.0.0.0', 9501);

        $http->on('Request', function ($request, $response) {
            $response->header('Content-Type', 'text/html; charset=utf-8');
            $response->end('<h1>Hello Swoole. #' . rand(1000, 9999) . '</h1>');
        });

        $http->start();
    }
}
